package com.salesmanager.web.utils.SMS;

/**
 * Created by 123 on 2015/9/21.
 */
public class GenerationSmsCode {

    //isdebug=true 点击发送后手机不会收到验证码，直接输入0000可通过验证
   // public static boolean isDebug=true;
//    coreConfiguration.getProperty(Constants.ALIYUN_ENDPOINT)
    /**
     * 创建指定数量的随机字符串
     * @return
     */
    public static String createRandom(boolean isDebug){
        if (isDebug)
            return "0000";

        String retStr ;
        String strTable = "1234567890";
        int len = strTable.length();
        boolean bDone = true;
        do {
            retStr = "";
            int count = 0;
            for (int i = 0; i < 4; i++) {
                double dblR = Math.random() * len;
                int intR = (int) Math.floor(dblR);
                char c = strTable.charAt(intR);
                if (('0' <= c) && (c <= '9')) {
                    count++;
                }
                retStr += strTable.charAt(intR);
            }
            if (count >= 2) {
                bDone = false;
            }
        } while (bDone);

        return retStr;
    }
}
